﻿using Microsoft.Extensions.DependencyInjection;
using MyCompany.MyProject.Common.Option;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyCompany.MyProject.Extensions.ServiceExtensions
{
    public static class AllOptionRegister
    {
        public static void AddAllOptionRegister(this IServiceCollection services)
        {
            if(services == null) throw new ArgumentNullException(nameof(services));
            
            var types = typeof(ConfigurableOptions).Assembly.GetTypes()
                .Where(i=>!i.IsInterface&& typeof(IConfigurableOptions).IsAssignableFrom(i));

            foreach(var optionType in types)
            {
                services.AddConfigurableOptions(optionType);
            }
        }
    }
}
